home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / batuti.arc / SETCWD.C < prev    next >
Text File  |  1990-01-10  |  884b  |  43 lines

  1. /*
  2.  *
  3.  *   setcwd -- sets the environment variable name in arg[1] to the current
  4.  *   working directory
  5.  *   Richard Connelly,(C) 1989,1990
  6.  *
  7.  */
  8.  
  9. #include <stdio.h>
  10. #include <conio.h>
  11. #include <process.h>
  12. #include <dos.h>
  13. #include <dir.h>
  14. #include <mem.h>
  15. #include "mst_env.h"
  16.  
  17. #define buflen 256
  18.  
  19. void main(int argc, char *argv[])
  20. {
  21.  
  22. /*
  23.  *         Determine if the user is using the command correctly
  24.  */
  25.  
  26.    char buf[buflen];
  27.  
  28.    if (argc == 1)
  29.    {
  30.       fprintf(stderr," usage:\n\t  setcwd env-name  \n");
  31.       exit(-1);
  32.     }
  33.  
  34. /*
  35.  *         Set the cwd to an environment variable provided via argv
  36.  */
  37.                     /* set the environment var passed */
  38.       getcwd(buf,buflen);
  39.       if ( m_putenv(argv[1],buf))
  40.      fprintf(stderr,"Out of environment space\n");
  41.       exit(0);                          /* by argv & terminate successfully */
  42. }
  43.